package com.example.mybatisxmltest.demos.web.controller;

import com.example.mybatisxmltest.demos.web.mapper.UserMapper;
import com.example.mybatisxmltest.demos.web.mapper.UserNotResourcesMapper;
import com.example.mybatisxmltest.demos.web.pojo.User;

import com.example.mybatisxmltest.demos.web.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class userController {
    @Autowired
    private IUserService iUserService;
    @Autowired
    private UserMapper userMapper;
    @Autowired
    private  UserNotResourcesMapper userNotResourcesMapper;

    @GetMapping ("/getUser")
    @ResponseBody
    public User getUser(@RequestParam(value = "id") String id){
        return iUserService.getUser(id);
    }


    @GetMapping ("/getUser2")
    @ResponseBody
    public String getUser2(){

        return "hello2";
    }
    @GetMapping ("/getUser3")
    @ResponseBody
    public User getUser3(@RequestParam(value = "id") Integer id,@RequestParam(value = "username") String  username,@RequestParam(value = "phone") String phone){
        System.out.println(id);
        System.out.println(username);
        System.out.println(phone);

        return iUserService.getUser3(id,username,phone);
    }


    @GetMapping("/getUser4")
    @ResponseBody
    public User getUser4(@RequestParam(value = "id") Integer id){
        return  userMapper.getUser4(id);
    }
    @GetMapping("/getUserNotResources")
    @ResponseBody
    public User getUserNotResources(@RequestParam(value = "id") Integer id,@RequestParam(value = "username") String username){
//        return  userNotResourcesMapper.getUserNotResourcesMapper(id,username); // 没问题的
        return  userNotResourcesMapper.getUserNotResourcesMapper(null,username);
    }




}
